<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>编辑分类</title>
    <style>
        .category{
            width: 600px;
            height: 300px;
            margin: 0 auto;
            text-align: left;
            border: 1px solid grey;
        }
        .category div{
            margin-top: 30px;
        }
        .category div:nth-child(1){
            width: 100%;
            height: 50px;
            background-color: rgb(0, 159, 149);
            line-height: 50px;
            padding-left: 20px;
            margin-top: 0;
            color: white;
            font-size: 19px;
        }
        .category div:nth-child(2){
            width: 90%;
            height: 50px;
            padding-left: 20px;
        }
        .category div:nth-child(2) span{
            text-align: center;
            line-height: 50px;
            display: inline-block;
            width: 20%;
            border: 1px solid grey;
            background-color: rgba(128, 128, 128, 0.07);
        }
        .category div:nth-child(2) input{
            width: 78%;
            height:52px;
        }
        .category_submit{
            width: 200px;
            height: 60px;
            margin-left: 200px;
        }
        .category_submit span:nth-child(1){
            display: inline-block;
            width: 64px;
            height:38px;
            background-color: rgb(0, 150, 136);
            line-height:38px;
            border-radius: 3px;
            text-align: center;
            color: #fff;
        }
        .category_submit span:nth-child(2){
            display: inline-block;
            width: 64px;
            height:38px;
            line-height:38px;
            border-radius: 3px;
            text-align: center;
            color: #333;
            margin-left: 10px;
            border: 1px solid rgb(230, 230, 230);
        }
    </style>
</head>
<body>
<div class="category">
    <div class="category_add">编辑产品分类</div>
    <div class="category_input">
        <span>分类名称</span>
        <input type="text" name="catename" value="{$oncate.catename}">
        <input type="hidden" name="id" value="{$oncate.id}">
    </div>
    <div class="category_submit">
        <span id="save">保存</span>
        <span id="cancle">取消</span>
    </div>
</div>
</body>
<script src="/assets/js/jquery-3.3.1.min.js" type="text/javascript"></script>
<script>
    $(function () {
        $('#save').click(function () {
            var catename = $('input[name=catename]').val();
            var id = $('input[type=hidden]').val();
            if(!catename){
                alert('分类不能为空！');
                return;
            }
            $.ajax({
                url: '/admin/productcate/editproductcate',
                data: {catename: catename, id: id},
                type: 'post',
                success:function (res) {
                    alert(res.info);
                    if(res.status) {
                        top.location.href = '/admin/productcate/category?ref=addtabs';
                    }
                }
            })
        })
        $('#cancle').click(function () {
            top.location.href = '/admin/productcate/category?ref=addtabs';
        })
    })
</script>
</html>

